package recoverLinkGraph;

import java.io.IOException;

import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

import removeDanglingPage.ReadBytes;

import mapred.AbstractMapper;

public class RecoverLinkGraph_Mapper extends AbstractMapper<BytesWritable, BytesWritable, BytesWritable, BytesWritable>{

	@Override
	public void map(BytesWritable key, BytesWritable value,
			OutputCollector<BytesWritable, BytesWritable> output,
			Reporter reporter) throws IOException {
		// TODO Auto-generated method stub
		ReadBytes k = new ReadBytes(key);
		byte[] p = k.nextUrl();
		k.next();
		int a = k.nextInt();
		if(a > 0) {
			output.collect(value, new BytesWritable(p));
		}
	}

//	@Override
//	public void map(Text key, Text value, OutputCollector<Text, Text> output,
//			Reporter reporter) throws IOException {
//		// TODO Auto-generated method stub
//		int pos = key.toString().trim().indexOf(" ");
//		String dp = key.toString().trim().substring(0, pos);
//		String num = key.toString().trim().substring(pos+1);
//		int d = Integer.parseInt(num);
//		if(d > 0) {
//			output.collect(value, new Text(dp));
//		}
//	}

}
